package com.asset.modules.common.utils;

import java.util.Date;
import java.util.Random;

/**
 * 管理编码生成
 * @author chenchen
 */
public class CodeGenerator {

    /**
     * 生成管理编码
     * @param projectCode   项目公司编码
     * @return
     */
    public static String generateManageCode(String projectCode){
        String year = DateUtils.formatDateToString(new Date(), DateUtils.DATE_FORMAT_Y);
        String cutYear = year.substring(2);
        System.out.println(Math.random());
        int randomNum = (int)(Math.random()*9999)+1;
        String manageCode = projectCode+cutYear+randomNum;
        return manageCode;
    }

    /**
     * 生成预算编码
     * @param prefixCode 项目编码
     * @return
     */
    public static String generateBudgetCode(String prefixCode){
//        String year = DateUtils.formatDateToString(new Date(), DateUtils.DATE_FORMAT_Y);
//        String cutYear = year.substring(2);
        int randomNum = (int)(Math.random()*999999)+1;
        String BudgetCode = prefixCode+randomNum;
        return BudgetCode;
    }

    public static void main(String[] args) {
        System.out.println(generateManageCode("Jiangsu001"));
    }
}
